{include file='public/header.html'}
{php $category=widget('common.category')->get()}

<div class="blog container mtn">

    <div class="row">
        <div class="col-sm-9">
            <article>
                <header>
                    <h3>
                        {if $vo['is_top']==1:}<span class="text-danger">置顶</span> {/if}{$vo.title}
                    </h3>
                    <div class="text-muted">
                        <a href="{:url('user/info',['id'=>$vo['user_id']])}"><i class="glyphicon glyphicon-user"></i> {$vo.author}</a>&nbsp;&nbsp;
                        <a href="{:url('article/index',['cid'=>$vo['user_id']])}"><i class="glyphicon glyphicon-th-large"></i> {$category[$vo['category_id']]}</a>&nbsp;&nbsp;
                        <i class="glyphicon glyphicon-time"></i> {:date('Y-m-d H:i:s', $vo['update_time'])}&nbsp;&nbsp;
                        <i class="glyphicon glyphicon-eye-open"></i> {$vo.read_count}&nbsp;&nbsp;
                        <span class="pull-right"><a href="javascript:history.back(-1);"><i class="glyphicon glyphicon-arrow-left"></i> 返回</a></span>
                    </div>
                </header>
                <section>
                {if $vo['is_display']==1:}
                    <div class="markdown-body">
                        {$vo.html}
                    </div>
                    {if !empty($vo['url']):}
                    <div class="mtn clearfix">
                        <a href="{$vo.url}" class="btn btn-success" target="_blank">点击前往</a>
                    </div>
                    {/if}
                {else:}
                    <div class="well clearfix">{$vo.summary}</div>
                    <p class="text-danger">该文章已隐藏，请输入密码查看。</p>
                    <form method="post" class="form-inline submit-ajax" action="{:url('article/check_password')}">
                        <input type="hidden" name="id" value="{$vo.id}" />
                        <div class="form-group">
                            <label for="password">访问密码：</label><input type="password" name="password" id="password" class="form-control" placeholder="请输入访问密码"/>
                        </div>
                        <button class="btn btn-primary">查看</button>
                    </form>
                {/if}

                </section>

            </article>
            <hr />
            <div class="clearfix">
                {php $tags=widget('common.tags')->get($vo['tag_ids'], ['key'=>'sign'])}
                {foreach $tags as $sign=>$name}
                <a href="{:url('article/index', ['tag'=>$sign])}">#{$name}</a>&nbsp;&nbsp;
                {/foreach}
            </div>
            <hr />
            <div class="clearfix">
                {php $related=get_related($vo['id'], 'article', ['order'=>'is_top DESC,update_time DESC,id DESC'])}
                {if !empty($related['prev']):}
                <span class="pull-left"><a href="{:url('article/detail',['id'=>$related['prev']['id']])}">上一篇：{$related.prev.title}</a></span>
                {/if}
                {if !empty($related['next']):}
                <span class="pull-right"><a href="{:url('article/detail',['id'=>$related['next']['id']])}">下一篇：{$related.next.title}</a></span>
                {/if}
            </div>
            <hr />
        </div>

        <div class="col-sm-3">

            <div class="panel panel-default">
                <div class="panel-heading">
                    <i class="glyphicon glyphicon-user"></i> 作者
                </div>
                <div class="panel-body">
                    {php $my=db('user')->field('id,avatar,qq,bio')->where('id', $vo['user_id'])->cache()->find()}
                    <div class="thumbnail text-center" style="margin-bottom: 0;">
                        <img src="{:get_avatar($my['avatar'], $my['qq'])}" width="80" height="80" class="img-circle" alt="avatar"/>
                        <div class="caption">
                            <p style="margin-top:5px;">
                                <a href="{:url('user/info',['id'=>$vo['user_id']])}"><strong>{$vo.author}</strong></a>
                            </p>
                            <p>#{$my.bio}</p>
                        </div>
                    </div>
                </div>
            </div>

            {include file='article/inc_sidebar.html'}
        </div>
    </div>

</div>

{include file='public/footer.html'}
<script src="__STATIC__/prism/prism.js" data-manual></script>
<script src="__STATIC__/js/clipboard.min.js"></script>
<script>
    $(document).ready(function () {
        $('pre').each(function () {
            if (!$(this).hasClass('line-numbers')) {
                $(this).addClass('line-numbers');
            }
        });
        let prefix = 'language-';
        let regex = new RegExp('\\b' + prefix + '[^ ]*');
        $('pre code').each(function () {
            if (!regex.test($(this).attr('class'))) {
                $(this).addClass(prefix + 'php'); //prefix + 'php'
            }
        });
        Prism.highlightAll(false);
        // 搜索
        $('#search').click(function () {
            "" != $("#keyword").val() ? location.href = "{:url('article/index')}?keyword=" + $("#keyword").val() : toast('请输入关键字');
        });
    });
</script>
</body>
</html>